<?php
/**
 * 题库模块
 * @author ChunYang.Jiang<chunyang@staff.sina.com.cn>
 * @version $Id$
 * @copyright sina
 * @date 2011-04-14
 */
class SubjectModule extends ModuleBase
{
	public static function add($row)
	{
		return parent::queryInsert($row, 'subject');
	}
	public static function get($where, $start, $limit)
	{
		return parent::querySelect(array('*'), $where, 'subject', 'priority asc', $start, $limit);
	}
	
	public static function getById($id)
	{
		return parent::querySelectSingle(array('*'), "id={$id}", 'subject');
	}
	
	public static function update($id, $row)
	{
		return parent::queryUpdate($row, "id={$id}", 'subject');
	}
	
	public static function getSubject($where, $start, $limit, &$total)
	{
		$res = parent::querySelectSingle(array('count(0) as num'), $where, 'subject');
		if ($res) {
			$total = intval($res['num']);
		}
		return parent::querySelect(array('*'), $where, 'subject', 'id desc', $start, $limit);
	}
}